package com.renjibo.childred.fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.renjibo.childred.R;


public class LookForFragment extends Fragment implements View.OnClickListener{

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mParam1;
    private String mParam2;
    private ImageView look_imageView_return;
    private Button look_buttonFor;
    private EditText look_editText;


    public LookForFragment() {
        // Required empty public constructor
    }


    public static LookForFragment newInstance(String param1, String param2) {
        LookForFragment fragment = new LookForFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_look_for, container, false);
        initView(view);
        return view;
    }
    public void initView(View view){
        look_imageView_return = (ImageView) view.findViewById(R.id.look_imageView_return);
        look_buttonFor = (Button) view.findViewById(R.id.look_buttonFor);
        look_editText = (EditText) view.findViewById(R.id.look_editText);
        look_imageView_return.setOnClickListener(this);
        look_buttonFor.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.look_imageView_return:
                getActivity().getSupportFragmentManager().popBackStack();
                break;
            //按钮
            case R.id.look_buttonFor:
                String mess=look_editText.getText().toString().trim();
                ResultFragment resultFragment=ResultFragment.newInstance(""+mess,"");
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.tabHost,resultFragment).addToBackStack("result").commit();
                break;
        }
    }
}
